import { DrawerForm, DrawerFormProps } from '@ant-design/pro-components'
import { BasicDrawerProps } from './index.type'
import styles from './index.module.less'

interface Props extends Omit<DrawerFormProps, 'open' | 'modalProps'> {
  register: BasicDrawerProps['register']
}

export function BasicDrawer({ register, width, children, ...argsProps }: Props) {
  const { visible, onClose } = register()

  return (
    <DrawerForm
      {...argsProps}
      open={visible}
      drawerProps={{
        width,
        onClose,
        destroyOnClose: true,
        className: styles.basicDrawer
      }}
    >
      {children}
    </DrawerForm>
  )
}
